package com.singzi.leetcode.N600;

import java.util.Arrays;
import java.util.HashMap;

public class T0506 {
    public static void main(String[] args) {
        Solution0506 solution0506 = new Solution0506();
        int []score = new int[]{2};
        System.out.println(Arrays.toString(solution0506.findRelativeRanks(score)));
    }
}
class Solution0506 {
    public String[] findRelativeRanks(int[] score) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < score.length; i++) {
            score[i] = -score[i];
            map.put(score[i], i); // 将值和下标存入Map
        }

        String[]result = new String[score.length];
        Arrays.sort(score);
        for (int i = 0; i < score.length; i++) {
            if(i==0) result[map.get(score[i])] = "Gold Medal";
            else if(i==1) result[map.get(score[i])] = "Silver Medal";
            else if(i==2) result[map.get(score[i])] = "Bronze Medal";
            else result[map.get(score[i])] = i+1 +"";
        }

        return result;
    }

}